package learn.spring.api.controller;


import java.util.List;
import learn.spring.api.service.IUserRoleService;
import learn.spring.common.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author chins
 * @since 2021-12-18
 */
@RestController
@RequestMapping("/api/user-role")
public class UserRoleController {

  @Autowired
  private IUserRoleService userRoleService;

  @GetMapping("/{userId}")
  public Result getRoleIdsByUserId(@PathVariable String userId) {
    List<String> roleIdsByUserId = userRoleService.getRoleIdsByUserId(userId);
    return Result.success().data("roleIds", roleIdsByUserId);
  }
}
